<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>滴答办公系统-学科列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/media/layui/css/layui.css" media="all">
<script src="/media/js/jquery.min.js"></script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>学科名称</td>
					<td>周数</td>
					<td>成立日期</td>
					<td>类型</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody id="tb">
		<c:forEach items="${pageUtils.recordsl}" var="major">
			<tr>
				<td>${major.id}</td>
				<td>${major.majorName}</td>
				<td>${major.majorTime}</td>
				<td>${major.majorDate}</td>
				<td>${major.majorType}</td>
				<td><a class="layui-btn layui-btn-mini" >编辑</a>
				    <a class="layui-btn layui-btn-danger layui-btn-mini" onclick="deleteCourse(${major.id});">删除</a> </td>
			</tr>
		</c:forEach>
			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
							<c:if test="${pageUtils.pageIndex==1}">
								   <a href="#" class="layui-laypage-prev layui-disabled" data-page="0">
										<i class="layui-icon">&lt;</i>
								   </a>
							</c:if>

							<c:if test="${pageUtils.pageIndex!=1}">
								<a href="/allMajorpage/${pageUtils.pageIndex-1}/${pageUtils.pageSize}" class="layui-laypage-prev " data-page="0">
									<i class="layui-icon">&lt;</i>
								</a>
							</c:if>

			               <c:forEach begin="${pageUtils.numberStart}" end="${pageUtils.numberEnd}" step="1" var="num">
                              <a href="/allMajorpage/${num}/${pageUtils.pageSize}" >${num}</a>
						   </c:forEach>

			             <c:if test="${pageUtils.pageIndex==pageUtils.pageCount}">
							<a href="#" class="layui-laypage-next layui-disabled" data-page="2">
								<i class="layui-icon">&gt;</i>
							</a>
						 </c:if>

						<c:if test="${pageUtils.pageIndex!=pageUtils.pageCount}">
							<a href="/allMajorpage/${pageUtils.pageIndex+1}/${pageUtils.pageSize}" class="layui-laypage-next " data-page="2">
								<i class="layui-icon">&gt;</i>
							</a>
						</c:if>

							<span class="layui-laypage-skip">到第
							   <input type="text" min="1" value="${pageUtils.pageIndex}" class="layui-input" id="page1"/>页
								<button type="button" class="layui-laypage-btn" onclick="topage()">确定</button>
							</span> 
							<span class="layui-laypage-count">共 ${pageUtils.allCount} 条</span>
							<span class="layui-laypage-limits"> 
							    <select lay-ignore="" onchange="tranform(this)">
							        <option value="3" ${pageUtils.pageSize==3?"selected":""}>3 条/页</option>
									<option value="5" ${pageUtils.pageSize==5?"selected":""}>5 条/页</option>
									<option value="10" ${pageUtils.pageSize==10?"selected":""}>10 条/页</option>
									<option value="15"  ${pageUtils.pageSize==15?"selected":""}>15条/页</option>
							</select>
							</span>
						</div>
	</div>
	<script src="/media/layui/layui.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(id){
		   layui.use('table', function() {
			   layer.confirm('是否确认删除学科?',function( ) {
			   	$.getJSON("/coursedel",{"id": id},function (result){
			   		if(result.status==200){
						layer.msg("删除成功", {icon : 6});
						location.reload();
					}else{
						layer.msg("删除失败", {icon : 5});
					}
				})
			   });
		   });
	   }


	   //页面跳转
	   function topage(){
	   	if($("#page1").val()<=${pageUtils.pageCount}){
	   		location.href="/allMajorpage/"+$('#page1').val()+"/"+${pageUtils.pageSize};
		}else{
	   		alert("请重新输入");
		}
	   }

	   //页面数据大小改变
	   function tranform(select){
	   	location.href="/allMajorpage/1/"+$(select).val();
	   }


	</script>
</body>
</html>